package com.uam.core.config;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Administrator
 */
public class IpLogConfig extends ClassicConverter {
    @Override
    public String convert(ILoggingEvent event) {
        try {
            InetAddress address = InetAddress.getLocalHost();
            String hostName = address.getHostName();
            String ip = address.getHostAddress();
            return hostName + "|" + ip;
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }
}
